package org.snia.server.cfg;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javax.xml.bind.annotation.XmlRootElement;

import org.snia.cdmi.model.MetaContainer;
import org.snia.cdmi.model.MetaDataObject;
import org.snia.cdmi.model.MetaSliceData;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

@XmlRootElement(name = "settings")
public final class ConfigurationSetting {
	
	private ClusterSetting cluster;
	private RouterEndpoint router;
	private DataCenterSetting dbcenter;
	private String id;
	private String name;
	private String host;
	private NetworkSetting network;
	private StorageConfiguration storage;
	//性能调优参数可能会单独形成一个文件，当前暂时放在一起。
	private OptimizeParameter paramter;
	
	
	public static void main(String[] args) {
		XStream xs = new XStream(new DomDriver());
		xs.alias("Container", MetaContainer.class);
		xs.alias("DataObject", MetaDataObject.class); 
		xs.alias("DataSlice", MetaSliceData.class);
		
		FileInputStream fis = null;
		Object object = null;
		try {
			fis = new FileInputStream("conf/db.xml");
			object = xs.fromXML(fis);
		} catch (FileNotFoundException ex) {
			return;
		} finally {
			try {
				if(fis != null){
					fis.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * @param cluster the cluster to set
	 */
	public void setClusterSetting(ClusterSetting cluster) {
		this.cluster = cluster;
	}

	/**
	 * @return the cluster
	 */
	public ClusterSetting getClusterSetting() {
		return cluster;
	}

	/**
	 * @param router the router to set
	 */
	public void setRouterEndpoint(RouterEndpoint router) {
		this.router = router;
	}

	/**
	 * @return the router
	 */
	public RouterEndpoint getRouterEndpoint() {
		return router;
	}

	/**
	 * @param dbcenter the dbcenter to set
	 */
	public void setDataCenterInfo(DataCenterSetting dbcenter) {
		this.dbcenter = dbcenter;
	}

	/**
	 * @return the dbcenter
	 */
	public DataCenterSetting getDataCenterInfo() {
		return dbcenter;
	}

	/**
	 * @param storage the storage to set
	 */
	public void setStorageConfiguration(StorageConfiguration storage) {
		this.storage = storage;
	}

	/**
	 * @return the storage
	 */
	public StorageConfiguration getStorageConfiguration() {
		return storage;
	}

	/**
	 * @param network the network to set
	 */
	public void setNetworkSetting(NetworkSetting network) {
		this.network = network;
	}

	/**
	 * @return the network
	 */
	public NetworkSetting getNetworkSetting() {
		return network;
	}

	/**
	 * @param host the host to set
	 */
	public void setHost(String host) {
		this.host = host;
	}

	/**
	 * @return the host
	 */
	public String getHost() {
		return host;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param paramter the paramter to set
	 */
	public void setOptimizeParameter(OptimizeParameter paramter) {
		this.paramter = paramter;
	}

	/**
	 * @return the paramter
	 */
	public OptimizeParameter getOptimizeParameter() {
		return paramter;
	}
}
